package com.rubiksillusions;

public class StringNormalizerTest {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		String in = "Z Z ";
		System.out.println(in);
		
		System.out.println(getExecutedMovesList(true, in));
	}
	
	public static String getExecutedMovesList(boolean normalized, String executedMovesList) {
		String[][] replacingStrings = {
				{ "Z Z ", "Z2 " },
				{ "Z2 Z2 ", " " }
		};
		
		StringBuffer normalizedMovesList = new StringBuffer(executedMovesList);
		StringBuffer oldNormalizedMovesList = new StringBuffer();
		if (normalized) {
			while (!normalizedMovesList.toString().equals(oldNormalizedMovesList.toString())) {
				System.out.println("In: $" + normalizedMovesList + "$ : $" + oldNormalizedMovesList + "$");
				oldNormalizedMovesList = new StringBuffer(normalizedMovesList);
				for (int i = 0; i < replacingStrings.length; i++) {
					normalizedMovesList = new StringBuffer(normalizedMovesList.toString().replaceAll(replacingStrings[i][0], replacingStrings[i][1]));
				}
			}
		}
		return normalizedMovesList.toString();
	}

}
